package com.heaboy.feedback.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.heaboy.feedback.domain.CourseClazz;
import com.heaboy.feedback.service.ICourseClazzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程班级Controller
 * 
 * @author heaboy
 * @date 2024-02-01
 */
@RestController
@RequestMapping("/feedback/courseclazz")
public class CourseClazzController extends BaseController
{
    @Autowired
    private ICourseClazzService courseClazzService;

    /**
     * 查询课程班级列表
     */
    @PreAuthorize("@ss.hasPermi('feedback:courseclazz:list')")
    @GetMapping("/list")
    public TableDataInfo list(CourseClazz courseClazz)
    {
        startPage();
        List<CourseClazz> list = courseClazzService.selectCourseClazzList(courseClazz);
        return getDataTable(list);
    }

    /**
     * 导出课程班级列表
     */
    @PreAuthorize("@ss.hasPermi('feedback:courseclazz:export')")
    @Log(title = "课程班级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseClazz courseClazz)
    {
        List<CourseClazz> list = courseClazzService.selectCourseClazzList(courseClazz);
        ExcelUtil<CourseClazz> util = new ExcelUtil<CourseClazz>(CourseClazz.class);
        util.exportExcel(response, list, "课程班级数据");
    }

    /**
     * 获取课程班级详细信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:courseclazz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(courseClazzService.selectCourseClazzById(id));
    }

    /**
     * 新增课程班级
     */
    @PreAuthorize("@ss.hasPermi('feedback:courseclazz:add')")
    @Log(title = "课程班级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseClazz courseClazz)
    {
        return toAjax(courseClazzService.insertCourseClazz(courseClazz));
    }

    /**
     * 修改课程班级
     */
    @PreAuthorize("@ss.hasPermi('feedback:courseclazz:edit')")
    @Log(title = "课程班级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseClazz courseClazz)
    {
        return toAjax(courseClazzService.updateCourseClazz(courseClazz));
    }

    /**
     * 删除课程班级
     */
    @PreAuthorize("@ss.hasPermi('feedback:courseclazz:remove')")
    @Log(title = "课程班级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(courseClazzService.deleteCourseClazzByIds(ids));
    }
}
